package com.hundsun.yr.universal.p2p.bean;

import android.content.Context;
import android.text.TextUtils;

import com.hundsun.mobile.zwgt.R;
import com.hundsun.yr.universal.library.utils.HsNumberUtils;

import java.io.Serializable;

/**
 * Created by xx on 2017/5/8.
 */
public class MyLoanListBeen implements Serializable{

    /**
     * amount : 100000.00
     * applyprogress : 10
     * next_repay_amt :
     * onsale_day : 2017-05-02
     * pay_method : 1
     * prdprogress : 0
     * prepayment_begin_date : 0000-00-00
     * prepayment_end_date : 0000-00-00
     * prepayment_flag : 1
     * rate : 13.0000
     * repayed_term :
     * total_interest : 13000.0000000000
     * total_term : 360
     * uuid : 000269
     */

    public String amount;
    public String applyprogress;
    public String next_repay_amt;
    public String onsale_day;
    public String pay_method;
    public String prdprogress;
    public String prepayment_begin_date;
    public String prepayment_end_date;
    public String prepayment_flag;
    public String rate;
    public String repayed_term;
    public String total_interest;
    public String total_term;
    public String uuid;
    /**
     * debt_rate : 8.5000
     * prdname : 徐大帅2
     * service_fee : 4.5000
     */

    public String debt_rate;
    public String prdname;
    public String service_fee;
    /**
     * apply_day : 2017-05-10
     * end_day : 2018-05-05
     * start_day : 2017-05-10
     * true_debt : 50000.00
     */

    public String apply_day;
    public String end_day;
    public String start_day;
    public String true_debt;
    /**
     * next_repay_day : 2017-06-13
     */

    public String next_repay_day;

    public String ctime;
    /**
     * retotal_term : 12
     */

    public String retotal_term;
    /**
     * repayment : 0 是否已经还款
     */

    public String repayment;
    /**
     * repay_time : 2017-06-05 11:26:26
     */

    /**
     * 真实的结清时间
     */
    public String repay_time;
    /**
     * canPay : 0表示  是否还款
     */

    public String canPay;

    /**
     * 获取募集状态--不断补充中
     * 0	未发布
     10	投标中
     15	待放款
     18	放款中
     20	计息中
     30	待返还（暂时不用）
     40	已返还
     50	已结束
     60	已撤销
     100	逾期未返还
     105	逾期部分返还（暂不开发）
     110	逾期已返还
     120	流标
     125	停售（募集期截止但未募满）
     130	风控拒绝放款
     200	逾期已返还(与11重复废弃)
     * @return
     */
    public String getPrdprogress(){
        if (TextUtils.equals(prdprogress,"0")){
            return "已审核";
        } else if (TextUtils.equals(prdprogress,"10")){
            return "投标中";
        } else if (TextUtils.equals(prdprogress,"15")){
            return "待放款";
        } else if (TextUtils.equals(prdprogress,"18")){
            return "放款中";
        } else if (TextUtils.equals(prdprogress,"20")){
            return "计息中";
        } else if (TextUtils.equals(prdprogress,"30")){
            return "待返还";
        } else if (TextUtils.equals(prdprogress,"40")){
            return "还款中";
        } else if (TextUtils.equals(prdprogress,"50")){
            return "已结束";
        } else if (TextUtils.equals(prdprogress,"60")){
            return "已撤销";
        } else if (TextUtils.equals(prdprogress,"100")){
            return "已逾期";
        } else if (TextUtils.equals(prdprogress,"105")){
            return "逾期部分返还";
        } else if (TextUtils.equals(prdprogress,"110")){
            return "已结束";
        } else if (TextUtils.equals(prdprogress,"120")){
            return "流标";
        } else if (TextUtils.equals(prdprogress,"125")){
            return "停售";
        } else if (TextUtils.equals(prdprogress,"130")){
            return "流标";
        } else if (TextUtils.equals(prdprogress,"200")){
            return "逾期已返还";
        } else {
            return "";
        }
    }

    /**
     * 0	银行处理中
     1	一审（风控）审批中
     2	二审（运营）审批中
     10	审批完成，已转产品。
     100	用户撤回
     110	一审（风控）拒绝
     120	二审（运营）拒绝
     * @return
     */
    public String getApplyProgress(){
        if (TextUtils.equals(applyprogress,"0")){
            return "待审核";
        } else if (TextUtils.equals(applyprogress,"1")){
            return "审核中";
        }else if (TextUtils.equals(applyprogress,"2")){
            return "审核中";
        }else if (TextUtils.equals(applyprogress,"10")){
            return "审核完成";
        }else if (TextUtils.equals(applyprogress,"100")){
            return "已撤回";
        }else if (TextUtils.equals(applyprogress,"110")){
            return "已拒绝";
        }else{
            return "已拒绝";
        }
    }

    public String getPayMethod(Context mcContext){
        String payMethod = "";
        switch (pay_method){
            case "1":
                payMethod = mcContext.getString(R.string.pay_method_1);
                break;
            case "2":
                payMethod = mcContext.getString(R.string.pay_method_2);
                break;
            case "3":
                payMethod = mcContext.getString(R.string.pay_method_3);
                break;
            case "4":
                payMethod = mcContext.getString(R.string.pay_method_4);
                break;
        }
        return payMethod;
    }

    public static String getPayMethod(String pay_method) {

        String limttype = "";

        switch (pay_method){
            case "1":
                limttype = "天";
                break;
            default :
                limttype = "月";
                break;
        }
        return limttype;
    }


    /**
     * 显示投资期限
     * @return
     */
    public String getTerm(){
        String duration= HsNumberUtils.numberFormat("##0", total_term)+getPayMethod(pay_method);
        return duration;
    }

    @Override
    public String toString() {
        return "MyLoanListBeen{" +
                "amount='" + amount + '\'' +
                ", applyprogress='" + applyprogress + '\'' +
                ", next_repay_amt='" + next_repay_amt + '\'' +
                ", onsale_day='" + onsale_day + '\'' +
                ", pay_method='" + pay_method + '\'' +
                ", prdprogress='" + prdprogress + '\'' +
                ", prepayment_begin_date='" + prepayment_begin_date + '\'' +
                ", prepayment_end_date='" + prepayment_end_date + '\'' +
                ", prepayment_flag='" + prepayment_flag + '\'' +
                ", rate='" + rate + '\'' +
                ", repayed_term='" + repayed_term + '\'' +
                ", total_interest='" + total_interest + '\'' +
                ", total_term='" + total_term + '\'' +
                ", uuid='" + uuid + '\'' +
                ", debt_rate='" + debt_rate + '\'' +
                ", prdname='" + prdname + '\'' +
                ", service_fee='" + service_fee + '\'' +
                ", apply_day='" + apply_day + '\'' +
                ", end_day='" + end_day + '\'' +
                ", start_day='" + start_day + '\'' +
                ", true_debt='" + true_debt + '\'' +
                ", next_repay_day='" + next_repay_day + '\'' +
                ", ctime='" + ctime + '\'' +
                ", retotal_term='" + retotal_term + '\'' +
                ", repayment='" + repayment + '\'' +
                ", repay_time='" + repay_time + '\'' +
                ", canPay='" + canPay + '\'' +
                '}';
    }
}
